package com.example.mapper;

import com.example.entity.MoodDiary;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MoodDiaryMapper {

    @Insert("INSERT INTO mood_diaries (user_id, diary_date, mood, note) " +
            "VALUES (#{userId}, #{diaryDate}, #{mood}, #{note})")
    int insertMoodDiary(MoodDiary diary);

    @Delete("DELETE FROM mood_diaries WHERE diary_id = #{diaryId}")
    int deleteMoodDiaryById(Integer diaryId);

    @Update("UPDATE mood_diaries SET mood = #{mood}, note = #{note} WHERE diary_id = #{diaryId}")
    int updateMoodDiary(MoodDiary diary);

    @Select("SELECT * FROM mood_diaries WHERE user_id = #{userId} ORDER BY diary_date DESC")
    List<MoodDiary> getMoodDiariesByUserId(Integer userId);
}
